package util;

/**
 * http工具类
 * 提供工响应头信息
 * 暂时提供
 * 200 正常
 * 404 找不到页面
 */
public class HttpProtocolUtil {
    //获取200的头文件
    public static String getHttpHeader200(long contentLength) {
        return "HTTP/1.1 200 OK\n" +
                "Content-Type: text/html;\n" +
                "Content-Length: " + contentLength + "\n" +
                "\r\n"; //头信息和本体信息需要隔一行

    }

    //获取404的头文件
    public static String getHttpHeader404() {
        String str404Html = "<h1>404 not found</h1>";
        return "HTTP/1.1 404 NOT Found\n" +
                "Content-Type: text/html;\n" +
                "Content-Length: " + str404Html.getBytes().length + "\n" +
                "\r\n" + str404Html;
    }
}
